package cn.u313.repository;

import cn.u313.entry.PresentEntry;
import cn.u313.entry.PresentRecordEntry;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PresentRecordRepository extends JpaRepository<PresentRecordEntry, Integer>, JpaSpecificationExecutor<PresentRecordEntry> {
//    @Query(nativeQuery = true,value = "SELECT * FROM `t_yjilu` where id = '89152' ")
//    JiLuEntry byQQ(String s);
//    @Query(nativeQuery = true,value = "select count(1) from t_yjilu where to_days(time) = to_days(now()) and qq0 = :qq and type=:type ")
//    int countByqqAndType(String qq,String type);
//    @Query(nativeQuery = true,value = "select count(1) from t_yjilu where to_days(time) = to_days(now()) and qq0 = :qq and qq1 =:qq1")
//    int countQqToQq1(String qq,String qq1);

    @Query(nativeQuery = true,value = "SELECT * FROM `t_present_record` where type =:type and Type_Present = '手动'")
    List<PresentRecordEntry> getAll(String type);

    @Query(nativeQuery = true,value = "SELECT * FROM `t_present_record` where type =:type and id=:code and  Type_Present = '手动'")
    PresentRecordEntry getById(String type, String code);
    @Query(nativeQuery = true,value = "SELECT count(1) FROM `t_present_record` WHERE name=:name and qq=:qq ")
    int getByNameAndQQ(String name, String qq);

    @Query(nativeQuery = true,value = "SELECT count(1) FROM `t_present_record` WHERE name=:name ")
    int getByName(String name);
//    public

}